<template>
  <div class="BrandSendApplic">
    <div class="Top">
      <van-form validate-first :class="{ smallFontSize: showEdition, mediumFontSize: !showEdition }">
        <div
          style="
            display: flex;
            justify-content: center;
            align-items: center;
            border-bottom: 1px solid #d2d2d2;
            color: black;
          "
        >
          <!-- <span style="color: #FF0000;">*</span> -->
          <van-field
            v-model="formData.HOUSEAPPLICANT"
            placeholder="请输入申请人姓名"
            label="申请人姓名"
            :rules="[{ required: true, message: '请填写户主姓名' }]"
          />
        </div>
        <div style="display: flex; justify-content: center; align-items: center; border-bottom: 1px solid #d2d2d2">
          <van-field v-model="formData.CERTIFICATECODE" label="申请人身份证号码" placeholder="申请人身份证号码" />
        </div>
        <div style="display: flex; justify-content: center; align-items: center; border-bottom: 1px solid #d2d2d2">
          <van-field
            placeholder="请输入申请人联系电话"
            v-model="formData.APPLYPHONE"
            label="申请人联系电话"
            :rules="[
              { required: true, message: '请填写您的手机号码！' },
              { pattern: /^1[3456789]\d{9}$/, message: '手机号码格式错误！' },
            ]"
            name="pattern"
          />
        </div>
        <div style="display: flex; justify-content: center; align-items: center; border-bottom: 1px solid #d2d2d2">
          <van-field v-model="formData.CONSTRUCITONADDRESS" label="农房地址" placeholder="农房地址" />
        </div>
      </van-form>
    </div>
    <div
      :class="{ smallFontSize: showEdition, mediumFontSize: !showEdition }"
      style="
        height: 50px;
        background: #007aff;
        line-height: 50px;
        text-align: center;
        color: #ffffff;
        font-weight: bold;
      "
      @click="handleSendSave"
    >
      提交
    </div>
  </div>
</template>
<script>
import { doorplate,FileServerProxy } from '@/utils/api'
export default {
  name: 'BrandSendApplic',
  data() {
    return {
      showEdition: false,
      formData: {},
    }
  },
  mounted() {
    if (ZWJSBridge) {
      ZWJSBridge.setTitle({
        title: '事项详情',
      })
        .then((res) => {})
        .catch((err) => {})
    }
    this.showEdition = this.$store.state.Edition
    this.formData = this.$route.query.data
  },
  methods: {
    handleSendSave: async function () {
      debugger
      if(this.formData.NWWIP==""|| this.formData.NWWIP==null || this.formData.NWWIP==undefined){
        this.$toast.fail("系统未配置地址！")
        return;
      }
      let AREACODE = '30'
      if (this.formData.AREACODE != null) {
        AREACODE = this.formData.AREACODE
      }
      let params = {
        accessCode: '16c9a20c2f0a4791bf74ead599270a23',
        cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '',
        params: {
          address: this.formData.CONSTRUCITONADDRESS,
          areaName: '杭州市',
          areaCode: AREACODE,
          propertyOwnerIdentityNumber: '11',
          propertyName: '111',
          proposerOwnerIdentityNumber: this.formData.CERTIFICATECODE,
          proposerName: this.formData.HOUSEAPPLICANT,
          proposerTelephone: this.formData.APPLYPHONE,
          id: this.formData.ROW_GUID,
          source: '1',
          coordinateSystem: '',
          attachmentList: [
            {
              name: '农村建房审批表',
              type: '105',
              url: this.formData.NWWIP.replaceAll("#",":")+'/PrintServer/api/PreviewWordRpt?groupGuid=%7B9DAD7750-9499-4751-A9E5-84B2EB9D25D0%7D&toRowGuid='+this.formData.ROW_GUID+'&dataGuid=01103ebf-a884-4282-b996-78dd64196946',
            },
            {
              name: '农村建房申请表',
              type: '110',
              url: this.formData.NWWIP.replaceAll("#",":")+'/PrintServer/api/PreviewWordRpt?groupGuid=%7B46892203-875E-4F7D-A337-CEF6D965CE44%7D&toRowGuid='+this.formData.ROW_GUID+'&dataGuid=01103ebf-a884-4282-b996-78dd64196946',
            },
          ],
        },
      }
      const res = await doorplate(params)

      if (res.data.code == 200 && JSON.parse(res.data.data)&&JSON.parse(res.data.data).code == 0) {
        //wjh 提交成功后修改值 2022-09-05 张志涵提供
        let xcfycjtex = {
              procName: 'MPBL',
              dtParams: JSON.stringify([{ I_USERID: this.formData.PKID, I_TYPE: 4 }]),
              token: window.localStorage.getItem('token'),
            }
            let xcfycjtfn = {
              accessCode: '69db6bece3a7480592e2ec753d1e335e',
              cityCode: window.localStorage.getItem('citycode')
                ? window.localStorage.getItem('citycode')
                : '441300000000',
              params: xcfycjtex,
            }
            const resxcfycjt = await FileServerProxy(xcfycjtfn)
        // let params = {
        //   accessCode: '',
        //   cityCode: window.localStorage.getItem('citycode') ? window.localStorage.getItem('citycode') : '441300000000',
        //   params: {
        //     dataGuid: '01103ebf-a884-4282-b996-78dd64196946',
        //     strParams: JSON.stringify([{PKID:this.formData.PKID,F_CREATETIME:new Date(),F_RESULT:1}]),
        //     token: window.localStorage.getItem('token'),
        //   },
        // }
        // params.accessCode = '77ad6c1591e54d4fbc45ecc90374a2a2'
        await FileServerProxy(params)
        //let data = JSON.parse(res.data.data).Success
        this.$toast.success(res.data.msg)
      } else {
        this.$toast.fail("提交失败!")
      }
    },
  },
}
</script>
<style lang="scss" scoped>
.BrandSendApplic {
  .Top {
    width: 100vw;
    overflow-x: hidden;
    height: calc(100vh - 50px);
    overflow-y: auto;
    background: #fff;
    padding: 0 10px;
  }
}
</style>
<style lang="scss">
.BrandSendApplic {
  .van-dialog__footer {
    background: transparent;
  }
  .el-form-item {
    width: 100% !important;
    margin-bottom: 0px !important;
    border-bottom: 1px solid #ccc;
  }
  .el-form-item__content {
    // width: 72% !important;
    text-align: right !important;
  }
  .el-form-item__label {
    /*font-size: 16px;*/
  }
  .van-field__label {
    width: auto !important;
  }
  .mediumFontSize {
    .van-field__label {
      font-size: 20px;
    }
  }
  .el-input__inner {
    /*font-size: 16px;*/
    text-align: right;
    border: none;
  }
  .van-cell:not(:last-child)::after {
    left: 0;
    // border-bottom: 1px solid rgb(210, 210, 210);
  }
  .van-cell::after {
    border-bottom: none;
  }
  .van-cell {
    padding: 10px 0;
    font-size: 16px;
  }
  .van-field__control {
    text-align: right;
  }
  textarea {
    text-align: left !important;
  }
}
.van-field__label {
  color: black !important;
  letter-spacing: 1px;
}
.van-cell {
  color: black;
}
</style>